/*
 * @Author: your name
 * @Date: 2022-01-22 10:09:19
 * @LastEditTime: 2022-04-18 14:48:00
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \my-app\src\redux\index.ts
 */
import { ReactElement } from 'react'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import logger from 'redux-logger'
import { composeWithDevTools } from 'redux-devtools-extension'
import reducer from './reducer'
export const store =
	process.env.NODE_ENV === 'development'
		? createStore(reducer, composeWithDevTools(applyMiddleware(thunk, logger)))
		: createStore(reducer, composeWithDevTools(applyMiddleware(thunk)))
export type RootState = ReturnType<typeof store.getState>
const Redux = ({ children }: { children: ReactElement }) => {
	return <Provider store={store}>{children}</Provider>
}

export default Redux
